import { IsString, IsOptional, IsArray, IsUrl } from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';

export class ParseNovelDto {
  @ApiProperty({ description: '小说分享链接' })
  @IsString()
  @IsUrl()
  url: string;

  @ApiPropertyOptional({ description: '来源平台' })
  @IsOptional()
  @IsString()
  platform?: string;
}

export class ConfirmImportDto {
  @ApiProperty({ description: '临时小说数据ID' })
  @IsString()
  tempId: string;

  @ApiProperty({ description: '小说标题' })
  @IsString()
  title: string;

  @ApiProperty({ description: '作者名称' })
  @IsString()
  author: string;

  @ApiPropertyOptional({ description: '小说封面URL' })
  @IsOptional()
  @IsString()
  cover?: string;

  @ApiPropertyOptional({ description: '小说分类' })
  @IsOptional()
  @IsString()
  category?: string;

  @ApiPropertyOptional({ description: '小说标签' })
  @IsOptional()
  @IsArray()
  tags?: string[];

  @ApiPropertyOptional({ description: '小说简介' })
  @IsOptional()
  @IsString()
  description?: string;

  @ApiPropertyOptional({ description: '章节数量' })
  @IsOptional()
  @IsString()
  chapterCount?: string;

  @ApiPropertyOptional({ description: '小说状态' })
  @IsOptional()
  @IsString()
  status?: string;

  @ApiPropertyOptional({ description: '字数统计' })
  @IsOptional()
  @IsString()
  wordCount?: string;

  @ApiPropertyOptional({ description: '更新时间' })
  @IsOptional()
  @IsString()
  updateTime?: string;
}

export class NovelInfoDto {
  @ApiProperty({ description: '小说标题' })
  title: string;

  @ApiProperty({ description: '作者名称' })
  author: string;

  @ApiPropertyOptional({ description: '小说封面URL' })
  cover?: string;

  @ApiPropertyOptional({ description: '小说分类' })
  category?: string;

  @ApiPropertyOptional({ description: '小说标签' })
  tags?: string[];

  @ApiPropertyOptional({ description: '小说简介' })
  description?: string;

  @ApiPropertyOptional({ description: '章节数量' })
  chapters?: number;

  @ApiPropertyOptional({ description: '小说状态' })
  status?: string;

  @ApiPropertyOptional({ description: '字数统计' })
  wordCount?: string;

  @ApiPropertyOptional({ description: '更新时间' })
  updateTime?: string;

  @ApiProperty({ description: '平台标识' })
  platform: string;

  @ApiProperty({ description: '平台名称' })
  platformName: string;

  @ApiProperty({ description: '原始链接' })
  originalUrl: string;

  @ApiPropertyOptional({ description: '章节列表' })
  chapterList?: Array<{
    title: string;
    url?: string;
    index: number;
    isFree?: boolean;
    content?: string;
    volumeName?: string;
  }>;
}
